<@>layout("/common/default.html"){
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <span lay-separator="">/</span>
        <a href="">邮件管理</a>
        <span lay-separator="">/</span>
        <a><cite>收件箱</cite></a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i>
    </a>
</div>
<div class="x-body">
    <div class="layui-row layui-col-space15">
        <table class="layui-table"
               lay-data="{id:'email-list', url:'${ctxPath}/ajax/email/mailHistory/list', page:true,request: {pageName: 'page' ,limitName: 'rows'} }"
               lay-filter="email-list">
            <thead>
            <tr>
                <th lay-data="{field:'title', width:400}">主题</th>
                <th lay-data="{field:'name', width:200}">发件人</th>
                <th lay-data="{field:'mail', width:200}">发送人邮箱</th>
                <th lay-data="{field:'createTime', width:200}">发送时间</th>
                <th lay-data="{field:'id', toolbar: '#toolbar',fixed:'right',width:520}">操作</th>
            </tr>
            </thead>
        </table>
    </div>
    <script type="text/html" id="toolbar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
    </script>
</div>
<script>
    $(function () {
        $("input").keydown(function() {
            if (event.keyCode == "13") {//keyCode=13是回车键
                $('#reSearch').click();
            }
        });

        layui.use('table', function () {
            var table = layui.table;
            table.on('tool(email-list)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent === 'edit') {//编辑
                    x_admin_show('邮件信息', '${ctxPath}/email/emailDetail?id=' + data.id, 1200, 800)
                }
            });
        });
    });

    //搜索
    function doSearch() {
        var state = $('#state').find('option:selected').val();
        state = state.length > 1 ? '' : state;
        layui.use('table', function () {
            var table = layui.table;
            table.reload('user-list', {
                url: '${ctxPath}/ajax/userpermission/user/list',
                where: {
                    username: $('#username').val(),
                    name: $('#name').val(),
                    state: state
                }//设定异步数据接口的额外参数
            });
        });
    }
</script>
<@>}